import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
import config from '../../package.json';

Vue.use(VueRouter);
const routes = [
  {path: '*' , component: () => import('../views/NotFound.vue')},
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {title: 'SDAY 2019'},
  },
  {
    path: '/member',
    name: 'Member',
    component: () => import('../views/Member.vue'),
    meta: { title: 'Member' },
    children: [
      {
        path: 'login',
        name: 'UserLogin',
        meta: {title: 'LOGIN'}
      },
      {
        path: 'forget',
        name: 'UserForget',
        meta: {title: 'FORGET'}
      },
      {
        path: 'register',
        name: 'UserRegister',
        meta: {title: 'REGISTER'}
      },
      {
        path: 'information',
        name: 'UserInformation',
        meta: {title: 'Account Information'},
        component: () => import('../views/Information.vue'),
        children: [
          {
            path: 'designer',
            name: 'UserInfoDesigner',
            meta: {title: 'Designer Information'}
          },
          {
            path: 'project',
            name: 'UserInfoProject',
            meta: {title: 'Project Information'}
          },
        ]
      },
    ]
  },
  {
    path: '/sday-2019',
    name: 'Sday2019',
    component: () => import('../views/Sday.vue'),
    meta: { title: 'sday-2019' },
    children: [
      {
        path: 'must-knows',
        name: 'MustKnows',
        meta: {title: 'MUST KNOWS'}
      },
      {
        path: 'about',
        name: 'Sday2019About',
        component: () => import('../views/About.vue'),
        meta: {title: 'ABOUT SDAY'}
      },
    ]
  },
  {
    path: '/nomination/:id?',
    name: 'Nomination',
    component: () => import('../views/Nomination.vue'),
    meta: {title: 'NOMINATION'}
  },
  {
    path: '/jury',
    name: 'Jury',
    component: () => import('../views/Jury.vue'),
    meta: {title: 'Jury'},
    children: [
      {
        path: 'panel/:year?/:id?',
        name: 'JuryPanel',
        meta: {title: 'JURY PANEL'}
      }, {
        path: 'info',
        name: 'JudgingInfo',
        component: () => import('../views/JuryInfo.vue'),
        meta: {title: 'JUDGING INFO'}
      },
    ]
  }, {
    path: '/archive/:year?/:page?',
    name: 'Archive',
    component: () => import('../views/Archive.vue'),
    meta: {title: 'ARCHIVE'},
  }, {
    path: '/media',
    name: 'Media',
    component: () => import('../views/Media.vue'),
    meta: {title: 'MEDIA'},
    children: [
      {
        path: 'press-release',
        name: 'PressRelease',
        component: () => import('../views/PressRelease.vue'),
        meta: {title: 'PRESS RELEASE'}
      }, {
        path: 'news/:id?',
        name: 'News',
        component: () => import('../views/News.vue'),
        meta: {title: 'News'}
      }, {
        path: 'videos',
        name: 'Videos',
        component: () => import('../views/Videos.vue'),
        meta: {title: 'VIDEOS'}
      }, {
        path: 'photos',
        name: 'Photos',
        component: () => import('../views/Photos.vue'),
        meta: {title: 'PHOTOS'}
      }
    ]
  }, {
    path: '/download',
    name: 'Download',
    component: () => import('../views/Download.vue'),
    meta: {title: 'DOWNLOAD'}
  },
];

const router = new VueRouter({
  routes,
  //mode: 'history'
});
router.beforeEach((to,from,next) => {
  if (to.meta.title) {
    document.title = `${to.meta.title} - ${config.name}`
  }
  next()
})

export default router;
